package com.yunzheng.studyLeaveSystem.modules.admin.search.trueSearch.servlet;

import com.alibaba.fastjson.JSON;
import com.yunzheng.studyLeaveSystem.modules.admin.search.trueSearch.entity.leaver;
import com.yunzheng.studyLeaveSystem.modules.admin.search.trueSearch.service.ShowLeaverService;
import com.yunzheng.studyLeaveSystem.modules.response.ResponseWrapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@WebServlet(value="/ShowLeaverServlet")
public class ShowLeaverServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        ShowLeaverService showleaverService = new ShowLeaverService();
        List<leaver> InformationList;
        try {
            InformationList = showleaverService.showInformation();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        ResponseWrapper responseWrapper = ResponseWrapper.Success(InformationList);
        String s = JSON.toJSONString(responseWrapper);
        PrintWriter writer = response.getWriter();
        writer.println(s);
        System.out.println(s);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
